Imports cmplib01

Public Class ctlSelectOOBUnit
    Inherits System.Windows.Forms.UserControl

    Public Event PointValueChanged(ByVal newval As Integer)

    Private ptrUnit As UnitType
    Private ptrCurrentGame As CampaignerGameData

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'UserControl overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents pnlCreateBattlegroup As System.Windows.Forms.Panel
    Friend WithEvents lblUnitPointValue As System.Windows.Forms.Label
    Friend WithEvents lblOOBUnitsHeader As System.Windows.Forms.Label
    Friend WithEvents lblPointValue As System.Windows.Forms.Label
    Friend WithEvents lstOOBUnits As System.Windows.Forms.ListBox
    Friend WithEvents pnlIcons As System.Windows.Forms.Panel
    Friend WithEvents lblFriendly As System.Windows.Forms.Label
    Friend WithEvents lblEnemy As System.Windows.Forms.Label
    Friend WithEvents lblOwner As System.Windows.Forms.Label
    Friend WithEvents picFriendly As System.Windows.Forms.PictureBox
    Friend WithEvents picEnemy As System.Windows.Forms.PictureBox
    Friend WithEvents picOwner As System.Windows.Forms.PictureBox
    Friend WithEvents lblOOBIcon As System.Windows.Forms.Label
    Friend WithEvents imlUnits As System.Windows.Forms.ImageList
    Friend WithEvents lblUniName As System.Windows.Forms.Label
    Friend WithEvents lblUnitName As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.pnlCreateBattlegroup = New System.Windows.Forms.Panel
        Me.lblUnitPointValue = New System.Windows.Forms.Label
        Me.lblOOBUnitsHeader = New System.Windows.Forms.Label
        Me.lblPointValue = New System.Windows.Forms.Label
        Me.lblUniName = New System.Windows.Forms.Label
        Me.lblUnitName = New System.Windows.Forms.Label
        Me.lstOOBUnits = New System.Windows.Forms.ListBox
        Me.lblOOBIcon = New System.Windows.Forms.Label
        Me.pnlIcons = New System.Windows.Forms.Panel
        Me.lblFriendly = New System.Windows.Forms.Label
        Me.lblEnemy = New System.Windows.Forms.Label
        Me.lblOwner = New System.Windows.Forms.Label
        Me.picFriendly = New System.Windows.Forms.PictureBox
        Me.picEnemy = New System.Windows.Forms.PictureBox
        Me.picOwner = New System.Windows.Forms.PictureBox
        Me.imlUnits = New System.Windows.Forms.ImageList(Me.components)
        Me.pnlCreateBattlegroup.SuspendLayout()
        Me.pnlIcons.SuspendLayout()
        Me.SuspendLayout()
        '
        'pnlCreateBattlegroup
        '
        Me.pnlCreateBattlegroup.BackColor = System.Drawing.Color.LightSkyBlue
        Me.pnlCreateBattlegroup.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlCreateBattlegroup.Controls.Add(Me.lblOOBIcon)
        Me.pnlCreateBattlegroup.Controls.Add(Me.pnlIcons)
        Me.pnlCreateBattlegroup.Controls.Add(Me.lstOOBUnits)
        Me.pnlCreateBattlegroup.Controls.Add(Me.lblUnitName)
        Me.pnlCreateBattlegroup.Controls.Add(Me.lblUnitPointValue)
        Me.pnlCreateBattlegroup.Controls.Add(Me.lblOOBUnitsHeader)
        Me.pnlCreateBattlegroup.Controls.Add(Me.lblPointValue)
        Me.pnlCreateBattlegroup.Controls.Add(Me.lblUniName)
        Me.pnlCreateBattlegroup.Location = New System.Drawing.Point(0, 0)
        Me.pnlCreateBattlegroup.Name = "pnlCreateBattlegroup"
        Me.pnlCreateBattlegroup.Size = New System.Drawing.Size(568, 400)
        Me.pnlCreateBattlegroup.TabIndex = 25
        '
        'lblUnitPointValue
        '
        Me.lblUnitPointValue.BackColor = System.Drawing.Color.White
        Me.lblUnitPointValue.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblUnitPointValue.Location = New System.Drawing.Point(416, 32)
        Me.lblUnitPointValue.Name = "lblUnitPointValue"
        Me.lblUnitPointValue.Size = New System.Drawing.Size(120, 21)
        Me.lblUnitPointValue.TabIndex = 41
        Me.lblUnitPointValue.Text = "0"
        Me.lblUnitPointValue.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'lblOOBUnitsHeader
        '
        Me.lblOOBUnitsHeader.BackColor = System.Drawing.Color.DarkSeaGreen
        Me.lblOOBUnitsHeader.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblOOBUnitsHeader.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(204, Byte))
        Me.lblOOBUnitsHeader.Location = New System.Drawing.Point(8, 64)
        Me.lblOOBUnitsHeader.Name = "lblOOBUnitsHeader"
        Me.lblOOBUnitsHeader.Size = New System.Drawing.Size(304, 17)
        Me.lblOOBUnitsHeader.TabIndex = 38
        Me.lblOOBUnitsHeader.Text = "Order Of Battle Units"
        '
        'lblPointValue
        '
        Me.lblPointValue.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(204, Byte))
        Me.lblPointValue.Location = New System.Drawing.Point(320, 36)
        Me.lblPointValue.Name = "lblPointValue"
        Me.lblPointValue.Size = New System.Drawing.Size(104, 24)
        Me.lblPointValue.TabIndex = 34
        Me.lblPointValue.Text = "Unit PV"
        '
        'lblUniName
        '
        Me.lblUniName.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(204, Byte))
        Me.lblUniName.Location = New System.Drawing.Point(8, 8)
        Me.lblUniName.Name = "lblUniName"
        Me.lblUniName.Size = New System.Drawing.Size(136, 24)
        Me.lblUniName.TabIndex = 31
        Me.lblUniName.Text = "Unit Name"
        '
        'lblUnitName
        '
        Me.lblUnitName.BackColor = System.Drawing.Color.White
        Me.lblUnitName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblUnitName.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(204, Byte))
        Me.lblUnitName.Location = New System.Drawing.Point(8, 32)
        Me.lblUnitName.Name = "lblUnitName"
        Me.lblUnitName.Size = New System.Drawing.Size(304, 23)
        Me.lblUnitName.TabIndex = 42
        Me.lblUnitName.Text = "Selected Unit Name"
        Me.lblUnitName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'lstOOBUnits
        '
        Me.lstOOBUnits.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lstOOBUnits.Location = New System.Drawing.Point(8, 80)
        Me.lstOOBUnits.Name = "lstOOBUnits"
        Me.lstOOBUnits.Size = New System.Drawing.Size(304, 314)
        Me.lstOOBUnits.TabIndex = 43
        '
        'lblOOBIcon
        '
        Me.lblOOBIcon.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(204, Byte))
        Me.lblOOBIcon.Location = New System.Drawing.Point(328, 296)
        Me.lblOOBIcon.Name = "lblOOBIcon"
        Me.lblOOBIcon.Size = New System.Drawing.Size(104, 24)
        Me.lblOOBIcon.TabIndex = 45
        Me.lblOOBIcon.Text = "Unit Icons"
        '
        'pnlIcons
        '
        Me.pnlIcons.BackColor = System.Drawing.Color.PowderBlue
        Me.pnlIcons.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlIcons.Controls.Add(Me.lblFriendly)
        Me.pnlIcons.Controls.Add(Me.lblEnemy)
        Me.pnlIcons.Controls.Add(Me.lblOwner)
        Me.pnlIcons.Controls.Add(Me.picFriendly)
        Me.pnlIcons.Controls.Add(Me.picEnemy)
        Me.pnlIcons.Controls.Add(Me.picOwner)
        Me.pnlIcons.Location = New System.Drawing.Point(328, 320)
        Me.pnlIcons.Name = "pnlIcons"
        Me.pnlIcons.Size = New System.Drawing.Size(224, 72)
        Me.pnlIcons.TabIndex = 44
        '
        'lblFriendly
        '
        Me.lblFriendly.Location = New System.Drawing.Point(152, 2)
        Me.lblFriendly.Name = "lblFriendly"
        Me.lblFriendly.Size = New System.Drawing.Size(56, 16)
        Me.lblFriendly.TabIndex = 14
        Me.lblFriendly.Text = "Friendly"
        Me.lblFriendly.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'lblEnemy
        '
        Me.lblEnemy.Location = New System.Drawing.Point(84, 2)
        Me.lblEnemy.Name = "lblEnemy"
        Me.lblEnemy.Size = New System.Drawing.Size(48, 17)
        Me.lblEnemy.TabIndex = 13
        Me.lblEnemy.Text = "Enemy"
        Me.lblEnemy.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'lblOwner
        '
        Me.lblOwner.Location = New System.Drawing.Point(12, 2)
        Me.lblOwner.Name = "lblOwner"
        Me.lblOwner.Size = New System.Drawing.Size(48, 16)
        Me.lblOwner.TabIndex = 12
        Me.lblOwner.Text = "Owner"
        Me.lblOwner.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'picFriendly
        '
        Me.picFriendly.BackColor = System.Drawing.Color.Black
        Me.picFriendly.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.picFriendly.Location = New System.Drawing.Point(162, 21)
        Me.picFriendly.Name = "picFriendly"
        Me.picFriendly.Size = New System.Drawing.Size(33, 33)
        Me.picFriendly.TabIndex = 11
        Me.picFriendly.TabStop = False
        '
        'picEnemy
        '
        Me.picEnemy.BackColor = System.Drawing.Color.Black
        Me.picEnemy.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.picEnemy.Location = New System.Drawing.Point(90, 21)
        Me.picEnemy.Name = "picEnemy"
        Me.picEnemy.Size = New System.Drawing.Size(33, 33)
        Me.picEnemy.TabIndex = 10
        Me.picEnemy.TabStop = False
        '
        'picOwner
        '
        Me.picOwner.BackColor = System.Drawing.Color.Black
        Me.picOwner.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.picOwner.Location = New System.Drawing.Point(18, 21)
        Me.picOwner.Name = "picOwner"
        Me.picOwner.Size = New System.Drawing.Size(33, 33)
        Me.picOwner.TabIndex = 9
        Me.picOwner.TabStop = False
        '
        'imlUnits
        '
        Me.imlUnits.ImageSize = New System.Drawing.Size(16, 16)
        Me.imlUnits.TransparentColor = System.Drawing.Color.Transparent
        '
        'ctlSelectOOBUnit
        '
        Me.Controls.Add(Me.pnlCreateBattlegroup)
        Me.Name = "ctlSelectOOBUnit"
        Me.Size = New System.Drawing.Size(568, 400)
        Me.pnlCreateBattlegroup.ResumeLayout(False)
        Me.pnlIcons.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public WriteOnly Property CurrentGame() As CampaignerGameData
        Set(ByVal Value As CampaignerGameData)
            ptrCurrentGame = Value
            If Not ptrCurrentGame Is Nothing Then
                ListOOBunits()
            End If
        End Set
    End Property

    Public Property Unit() As UnitType
        Get
            Return ptrUnit
        End Get
        Set(ByVal Value As UnitType)

        End Set
    End Property

    Private Sub populateIcons()

        picOwner.Image = ptrUnit.Icon(IconImageIndex_cgd.Owner)
        picEnemy.Image = ptrUnit.Icon(IconImageIndex_cgd.Enemy)
        picFriendly.Image = ptrUnit.Icon(IconImageIndex_cgd.SameFaction)

    End Sub

    Private Sub ListOOBunits()
        Dim uni As UnitType

        lstOOBUnits.Items.Clear()

        For Each uni In ptrCurrentGame.selectedFaction.OrderOfBattle

            lstOOBUnits.Items.Add(uni)

        Next

    End Sub

    Private Sub lstOOBUnits_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstOOBUnits.SelectedIndexChanged
        If lstOOBUnits.Items Is Nothing Then Exit Sub

        ptrUnit = lstOOBUnits.SelectedItem
        populateIcons()
        lblUnitName.Text = ptrUnit.Name

        lblUnitPointValue.Text = ptrUnit.InitialPointValue
        RaiseEvent PointValueChanged(ptrUnit.InitialPointValue)

    End Sub
End Class
